<template>
  <div class="user-input-container">
    <input
      v-model="message"
      @keyup.enter="sendMessage"
      placeholder="和机器人聊天"
      class="message-input"
    />
    <button @click="sendMessage" class="message-button">
      <span class="arrow-icon">→</span>
    </button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      message: "",
    };
  },
  methods: {
    sendMessage() {
      if (this.message.trim()) {
        this.$emit("sendMessage", this.message);
        this.message = "";
      }
    },
  },
};
</script>

<style scoped>
.user-input-container {
  display: flex;
  align-items: center;
  background-color: #f8f9fa;
  border: 1px solid #ced4da;
  border-radius: 1rem;
  padding: 6px;
}

.message-input {
  flex: 1;
  height: 40px;
  width: 90%;
  padding: 0 12px;
  border: 0;
  border-top-left-radius: 1rem;
  border-bottom-left-radius: 1rem;
  font-size: 14px;
  color: #6c757d;
  background-color: #ffffff;
  outline: none;
}

.message-input::placeholder {
  color: #6c757d;
}

.message-button {
  height: 40px;
  background-color: #007bff;
  color: white;
  border: none;
  padding: 0 12px;
  border-radius: 1.2rem;
  cursor: pointer;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: background-color 0.2s ease;
}

.message-button:hover {
  background-color: #0056b3;
}

.arrow-icon {
  font-size: 18px;
}
</style>
